PESelectPrinter
Use PESelectPrinter to specify a printer other than the default printer as the print destination for the specified print job. You can use this function to enable the user to select a printer other than the default printer at print time. One way of doing this is to have your application call the Print Setup common dialog box.
C Syntax
BOOL CRPE_API PESelectPrinter (
short printJob,
const char FAR *driverName,
const char FAR *printerName,
const char FAR *portName,
DEVMODEA FAR *mode );
Parameters
printJob
| Specifies the print job for which you want to select a printer.
|
driverName
| Specifies a pointer to a null-terminated string that contains the name of the printer driver for the selected printer.
|
printerName
| Specifies a pointer to a null-terminated string that contains the printer name for the selected printer.
|
portName
| Specifies a pointer to a null-terminated string that contains the port name for the port to which the selected printer is attached.
|
mode
| Specifies a pointer to the DEVMODE, Windows API structure.
|
Returns
- TRUE if the call is successful.
- FALSE if the call fails.
Remarks
- The PRINTDLG structure returned by the Windows API PrintDlg function contains handles to DEVMODEA and DEVNAMES structures. This information can be used to obtain driverName, printerName, portName, and mode values for PESelectPrinter.
- Your code must parse the return from the dialog box selection and insert the returned Printer Driver Name, Printer Name, and Port Name as parameters in the call.
- After selecting the printer with this call, you can direct the output to that printer (using PEOutputToPrinter) or to the preview window (using PEOutputToWindow).
- This call will override a printer selection that you built into the report at design time via the Crystal Reports Select Printer menu command.
- If you follow this call with the call PEOutputToWindow, the report appears in the
preview window.
- To revert to the default printer, pass 0 for each parameter.
- The driver name and printer name must exist on your machine.
- You can specify a different printer port than that assigned to the selected printer on your machine.
- For parameter mode, use 0 for the default mode or create a DEVMODE, structure to customize (if your development tool supports such a structure).
- This function should be called before PEStartPrintJob, or the results may be inconsistent or unexpected.
VB Syntax
Declare Function PESelectPrinter Lib "crpe32.dll" ( ByVal printJob As
Integer,
ByVal PrinterDriver As String, ByVal PrinterName As String,
ByVal PortName As String, DevMode As Any ) As Integer
Delphi Syntax
function PESelectPrinter(
printJob: Word;
driverName: PChar;
printerName: PChar;
portName: PChar;
mode: PDeviceModeA
): Bool stdcall;